package com.hbo.timer;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author songxulin
 * @date 2022/3/18
 */
public class TimerTest {

    public static void main(String[] args) throws Exception{
        Timer timer = new Timer();
        for (int i = 0; i < 2; i++) {
            TimerTask t = new FooTimerTask("task"+i);
            timer.schedule(t,new Date(),2000);
        }
    }


}
class FooTimerTask extends TimerTask{
    private String name;

    public FooTimerTask(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println(new Date());
        System.out.println(name);
    }
}
